<template>
<div class="contains">
  <!-- 新增窗口 -->
  <a-modal v-model:visible="visible" title="新增管理员信息" @ok="execAdd">
    <a-form
      ref="fromRef"
      :model="addObj"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 14 }"
    >
      <a-form-item label="账号">
        <a-input v-model:value="addObj.m_id" />
      </a-form-item>
      <a-form-item label="名字">
        <a-input v-model:value="addObj.m_name" />
      </a-form-item>
      <a-form-item label="性别">
        <a-select v-model:value="addObj.m_sex" style="width: 160px">
          <a-select-option value=1>男</a-select-option>
          <a-select-option value=0>女</a-select-option>
        </a-select>
      </a-form-item>
      <a-form-item label="角色">
        <a-select v-model:value="addObj.m_status" style="width: 160px">
          <a-select-option value="c_admin">影院管理员</a-select-option>
        </a-select>
      </a-form-item>
      <a-form-item label="所属电影院">
        <a-select v-model:value="addObj.cnm_id" style="width: 160px">
          <a-select-option value=0>暂无</a-select-option>
          <a-select-option value=1>万达影院</a-select-option>
          <a-select-option value=2>星美影院</a-select-option>
          <a-select-option value=3>自由人影院</a-select-option>
          <a-select-option value=4>新房昭之影院</a-select-option>
        </a-select>
      </a-form-item>
    </a-form>
  </a-modal>
</div>
</template>
<script>
//新增
import { ref, reactive } from "vue";
import { post, tip } from "@/common";

export default {
  setup(props, { emit }) {
    const fromRef = ref();
    const addObj = reactive({
      m_id: "",
      m_name: "",
      m_sex:"1",
      m_status: "c_admin",
      cnm_id:"0",
    });
    const visible = ref(false);

    const open = () => {
      visible.value = true;
    };

    const execAdd = () => {
      //执行新增
      post("/security/c_admin", addObj).then((res) => {
        emit("ok");
        addObj.m_id = "";
        addObj.m_name = "";
        addObj.m_sex = "1";
        addObj.m_status = "c_admin";
        addObj.cnm_id="0";
        visible.value = false;
        tip.success("新增管理员成功！");
      });
    };

    return {
      addObj,
      visible,
      execAdd,
      open,
      fromRef,
      
    };
  },
};
</script>
<style scoped>
.contains{
  padding: 10px;
}
</style>